// Boost.STL2 library
//
//  Copyright Fernando Pelliccioni 2012.
//  Use, modification and distribution is subject to the Boost Software
//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//

// g++ -I"D:/Program Files/Boost/boost_1_49_0" -O3 -std=c++11 test_string.cpp

#include <iostream>
//#include <string>
#include "string.hpp"				//TODO: replace path
#include "range_access.hpp"			//TODO: replace path
#include "range_access_backward.hpp"	//for all(std::string)
#include "substr_range.hpp"	//for all(std::string)

//TODO: asserts en general.


template <typename Rng>
void print_range( Rng rng )
{
	for ( ; !rng.empty(); rng.pop_front() )
	{
		auto data = rng.front();
		std::cout << data;
	}
}


int main( /* int argc, char* argv[] */ )
{
	using boost::container::all;
	//using std2::all;

	{
		boost::container::string line = "this is a test";
		//auto rng = line.all();
		auto rng = all(line);

		print_range(rng);
		std::cout << std::endl;
	}

	{
		std::string line = "this is a test";
		auto rng = all(line);

		print_range(rng);
		std::cout << std::endl;
	}



	{
		using boost::container::substr_range;

		boost::container::string line = "this is a test";

		auto rng = substr_range(line, 0, 0);
		print_range(rng);
		std::cout << std::endl;

		rng = substr_range(line, 0, 14);
		print_range(rng);
		std::cout << std::endl;

		rng = substr_range(line, 0, 15);		//se va
		print_range(rng);
		std::cout << std::endl;


		rng = substr_range(line, 1, 14);		//se va
		print_range(rng);
		std::cout << std::endl;


		rng = substr_range(line, 1, 200);		//se va
		print_range(rng);
		std::cout << std::endl;


		rng = substr_range(line, 14, 200);	//se va
		print_range(rng);
		std::cout << std::endl;


		rng = substr_range(line, 0, 1);
		print_range(rng);
		std::cout << std::endl;


		rng = substr_range(line, 0, 2);
		print_range(rng);
		std::cout << std::endl;

		rng = substr_range(line, 0, 3);
		print_range(rng);
		std::cout << std::endl;


		rng = substr_range(line, 1, 0);
		print_range(rng);
		std::cout << std::endl;


		rng = substr_range(line, 1, 1);
		print_range(rng);
		std::cout << std::endl;

		rng = substr_range(line, 1, 2);
		print_range(rng);
		std::cout << std::endl;

		rng = substr_range(line, 1, 3);
		print_range(rng);
		std::cout << std::endl;


		//rng = substr_range(line, 15, 200);	//runtime error
		//print_range(rng);
		//std::cout << std::endl;
	}



	//{
	//	boost::container::string line = "this is a test";

	//	for ( auto c : line )
	//	{
	//		std::cout << c;
	//	}
	//}


	std::cout << std::endl;
	

	return 0;
}
